<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="__STATIC__/bootstrap-table/js/dropdown.js"></script>
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap-table.min.css">
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap.css">
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">

</head>
<body>
<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon" style="line-height:30px">ဂ</i></a>
<form class="layui-form" action="" onsubmit="return false" id="up">
    <br>
    <input type="text" value="{$data.id}" hidden id="id">
    <div class="layui-form-item" style="width: 50%">
        <label class="layui-form-label" style="width: 100px">协议标题</label>
        <div class="layui-input-block">
            <input type="text" value="{$data.title}" id="title"  placeholder="请输入标题" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text"  style="width: 50%">
        <label class="layui-form-label" style="width: 100px">协议详细</label>
        <div class="layui-input-block">
            <textarea lay-verify="article_desc" id="demo"  name="text" style="width: 100%;height: 100px">{$data.text|htmlspecialchars_decode}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo" id="add">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
</html>
<script>
    layui.use('layedit', function(){
        layedit = layui.layedit;
        index = layedit.build('demo', {tool: [
            'strong' //加粗
            ,'italic' //斜体
            ,'underline' //下划线
            ,'del' //删除线
        ]}); //建立编辑器
        //layedit.sync(index);
        edit = layedit.getContent(index);
    });
</script>
<script>
    $("#add").click(function(){
        var text = layedit.getContent(index);
        var id   = $("#id").val();
        var title= $("#title").val();
        $.ajax({
            url:"{:url('/protocol/updateProtocol')}",
            type:"post",
            data:{id:id,text:text,title:title},
            dataType:"json",
            success: function (res) {
                if (res.code) {
                    layer.msg(res.msg, {icon: 1, time: 2000}, function () {
                        window.location.reload();
                    });
                    return;
                } else {
                    layer.msg(res.msg, {icon: 5, time: 2000});
                    return;
                }
            }
        })
    })
</script>